var e, t = function(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}(require("../../../utils/tools.js"));

getApp();

Page({
    data: {
        pageName: "pdd",
        activeIndex: 0,
        page: 1,
        isover: !1,
        pdd_keyword: ""
    },
    onLoad: function(t) {
        e = this;
    },
    showInput: function() {
        wx.navigateTo({
            url: "/bh_farm/pages/search/search"
        });
    },
    tabClick: function(t) {
        var a = t.currentTarget.dataset.index;
        this.setData({
            isover: !1,
            page: 1,
            activeIndex: a,
            pdd_keyword: ""
        }), e.loadGoods();
    },
    click_nav_det: function(e) {
        var t = e.currentTarget.dataset.goods_id;
        wx.navigateTo({
            url: "/bh_farm/pages/pdd_details/pdd_details?goods_id=" + t
        });
    },
    loadGoods: function() {
        var a = this.data.category[this.data.activeIndex].opt_id, o = {
            action: "goods",
            contr: "pdd",
            token: wx.getStorageSync("token"),
            page: e.data.page,
            opt_id: a,
            pdd_keyword: this.data.pdd_keyword
        };
        t.default.request(o, function(t) {
            var a = t.info.pddGoodsList;
            e.data.page > 1 && (a = e.data.pddGoodsList.concat(a)), e.setData({
                pddGoodsList: a
            }), t.info.pddGoodsList < 10 && e.setData({
                isover: !0
            });
        });
    },
    onReachBottom: function() {
        this.data.isover || (this.data.page++, this.loadGoods());
    },
    onReady: function() {
        var a = {
            action: "category",
            contr: "pdd",
            token: wx.getStorageSync("token")
        };
        t.default.request(a, function(t) {
            e.setData(t.info), t.info.category && e.loadGoods();
        });
    },
    hideInviteRed: function() {
        this.setData({
            invite_red_show: !1
        });
    },
    showInviteRed: function() {
        this.setData({
            invite_red_show: !0
        });
    },
    hideSell: function() {
        this.setData({
            showSell: !1
        });
    },
    onSellEgg: function() {
        this.setData({
            showSell: !0
        });
    },
    onShow: function() {},
    gotoTelephoneBill: function() {
        wx.navigateTo({
            url: "/bh_farm/pages/exchange/exchange"
        });
    },
    navigatorSwitch: function(e) {
        console.log(e.detail.pageName);
        var t = e.detail.pageName;
        if (t != this.data.pageName) {
            if ("index" == t) a = "/bh_farm/pages/index/index"; else if ("recruit" == t) a = "/bh_farm/pages/recruit/recruit"; else if ("mine" == t) a = "/bh_farm/pages/my/my"; else if ("db" == t) var a = "/bh_farm/pages/treasure/treasure";
            wx.redirectTo({
                url: a
            });
        }
    },
    onShareAppMessage: function() {
        return {
            title: this.data.share.text,
            imageUrl: this.data.share.images,
            path: "bh_farm/pages/index/index?parent_id=" + this.data.share.member_id
        };
    },
    getUserInfo: function(a) {
        if ("getUserInfo:ok" == a.detail.errMsg) {
            var o = {
                action: "register",
                contr: "home",
                token: wx.getStorageSync("token"),
                encryptedData: a.detail.encryptedData,
                iv: a.detail.iv
            };
            t.default.request(o, function(t) {
                e.onReady(), e.showInviteRed();
            });
        }
    }
});